import itertools
import string


def brute_force_attack(target_password, max_length=8):
    """
    尝试暴力破解密码。

    :param target_password: 目标密码
    :param max_length: 密码的最大长度
    """
    chars = string.ascii_letters + string.digits  # 包含大小写字母和数字
    for length in range(1, max_length + 1):
        for guess in itertools.product(chars, repeat=length):
            guess_password = ''.join(guess)
            if guess_password == target_password:
                print(f"密码已找到: {guess_password}")
                return True
    print("密码未找到")
    return False


if __name__ == "__main__":
    target_password = "abc123"  # 设置目标密码
    brute_force_attack(target_password)